from pyecharts.charts import Page

from ranking import get_ranking
from draw_pie_line import draw_pie_line
from pi import getRadar


# 程序执行入口
if __name__ == '__main__':

    keyword = input("Input the keyword: ")

    page = Page()

    ups, rank = get_ranking(keyword)
    radars = getRadar(keyword, ups)
    ups = [str(x) for x in ups]
    pie_lines = draw_pie_line(keyword, ups)

    page.add(rank)
    for i in range(len(ups)):
        page.add(pie_lines[2 * i])
        page.add(pie_lines[2 * i + 1])
        page.add(radars[2 * i])
        page.add(radars[2 * i + 1])

    page.render(keyword + ".html")

    print("结果输出成功")